package com.tj.api.rest.account.response;

import com.alibaba.fastjson.JSONArray;
import com.fqgj.common.utils.StringUtils;
import com.tj.bo.account.client.vo.WithdrawRecordVO;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * Author: binary
 * Date: 2020/8/11 上午11:11
 */
public class WithdrawProgressResponse implements Serializable {

    private String applyTime;
    private BigDecimal amount;
    private String status;
    private Integer statusCode;
    private String account;
    private String rejectReason;
    private String faqUrl;
    private List<FAQItem> faqList;

    public WithdrawProgressResponse(WithdrawRecordVO withdrawRecordVO, String faqStr, String faqMoreUrl) {
        this.applyTime = withdrawRecordVO.getApplyTime();
        this.amount = withdrawRecordVO.getAmount();
        this.status = withdrawRecordVO.getStatus();
        //-2状态映射到客户端-1  -1对于客户端是失败页面
        this.statusCode = withdrawRecordVO.getStatusCode() == -2 ? -1 : withdrawRecordVO.getStatusCode();
        this.account = withdrawRecordVO.getAccount();

        String rejectReasonTmp = withdrawRecordVO.getFailureReasons();
        if (withdrawRecordVO.getStatusCode() == -2) {
            rejectReasonTmp = StringUtils.isNotEmpty(withdrawRecordVO.getFailureReasons()) ? withdrawRecordVO.getFailureReasons() : "Bank card error, please modify and then withdraw again";
        } else if (withdrawRecordVO.getStatusCode() == -1) {
            rejectReasonTmp = "The submitted information does not match, please withdraw again";
        }

        this.rejectReason = rejectReasonTmp;
        this.faqUrl = faqMoreUrl;
        this.faqList = JSONArray.parseArray(faqStr, FAQItem.class);
    }

    public String getApplyTime() {
        return applyTime;
    }

    public WithdrawProgressResponse setApplyTime(String applyTime) {
        this.applyTime = applyTime;
        return this;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public WithdrawProgressResponse setAmount(BigDecimal amount) {
        this.amount = amount;
        return this;
    }

    public String getStatus() {
        return status;
    }

    public WithdrawProgressResponse setStatus(String status) {
        this.status = status;
        return this;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public WithdrawProgressResponse setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
        return this;
    }

    public String getAccount() {
        return account;
    }

    public WithdrawProgressResponse setAccount(String account) {
        this.account = account;
        return this;
    }

    public String getRejectReason() {
        return rejectReason;
    }

    public WithdrawProgressResponse setRejectReason(String rejectReason) {
        this.rejectReason = rejectReason;
        return this;
    }

    public String getFaqUrl() {
        return faqUrl;
    }

    public WithdrawProgressResponse setFaqUrl(String faqUrl) {
        this.faqUrl = faqUrl;
        return this;
    }

    public List<FAQItem> getFaqList() {
        return faqList;
    }

    public WithdrawProgressResponse setFaqList(List<FAQItem> faqList) {
        this.faqList = faqList;
        return this;
    }

    private static class FAQItem {
        private String title;
        private String body;

        public FAQItem() {
        }

        public FAQItem(String title, String body) {
            this.title = title;
            this.body = body;
        }

        public String getTitle() {
            return title;
        }

        public FAQItem setTitle(String title) {
            this.title = title;
            return this;
        }

        public String getBody() {
            return body;
        }

        public FAQItem setBody(String body) {
            this.body = body;
            return this;
        }
    }
}
